package authentication.token.server;

import authentication.token.Request;
import authentication.token.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 模拟服务端
 *
 * @author yuqi<307530884@qq.com> <2017/3/28>
 * @version 1.0
 * @since 1.0
 */
public class Server {

	protected transient static final Logger LOGGER = LoggerFactory.getLogger(Server.class);

    private transient final Logger logger = LoggerFactory.getLogger(getClass());

    private Filter authFilter = new AuthFilter();
    private LoginController loginController = new LoginController();


    /**
     * 假设只有一个过滤器和一个登录接口
     */
    public void doService(Request request, Response response){

        if(!authFilter.doFilter(request, response)){
            logger.error("authFilter error");
            return;
        }

        loginController.loginIn(request, response);
    }

    public static Response doSend(Request request){
        Response response = new Response();

        new Server().doService(request, response);

        return response;
    }

}
